package com.dt.dubai.sys.controller;

import com.dt.dubai.sys.entity.SysAdminLoginEntity;
import com.dt.dubai.sys.controller.innate.SysAdminLoginInnateAbs;
import com.dt.dubai.core.comm.*;
import com.dt.dubai.core.utile.DateTools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/*
* 系统用户登录表
*/

@Controller
@RequestMapping(value = "/sys/sysAdminLogin")
public class SysAdminLoginController extends SysAdminLoginInnateAbs {

    /*innateServiceStart*/
    @Override
    protected void userSavEntity(SysAdminLoginEntity inEntity, final Long userId) {
        inEntity.setDelSign(false);
    }

    @Override
    protected void userModEntity(SysAdminLoginEntity inEntity, final Long userId) {
    }

    @Override
    protected void userDelByKey(List<Long> recordIds, final Long userId) {
    }

    @Override
    protected void userQueByKey(Long recordId, Map<String, Object> map, final Long userId) {
        if (null != map && map.size() > 0) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            map.remove("superUserRecordId");
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    @Override
    protected void userQuePageList(PageParameterData queryCondition, List<PageCondition> joinCondition, List<Map<String, Object>> resultMap, final Long userId) {
        for (Map<String, Object> map : resultMap) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            Short realNameType = null == map.get("realNameType") ? -1 :  (Short) map.get("realNameType");
            switch (realNameType) {
                case 0:
                    map.put("realNameType", realNameType);
                    map.put("realNameTypeStr", "未实名");
                    break;
                case 1:
                    map.put("realNameType", realNameType);
                    map.put("realNameTypeStr", "个人");
                    break;
                case 2:
                    map.put("realNameType", realNameType);
                    map.put("realNameTypeStr", "公司");
                    break;
                case 3:
                    map.put("realNameType", realNameType);
                    map.put("realNameTypeStr", "员工");
                    break;
                default:
                    map.put("realNameType", -1);
                    map.put("realNameTypeStr", "未知");
            }
            Short homePageType = null == map.get("homePageType") ? -1 :  (Short) map.get("homePageType");
            switch (homePageType) {
                case 1:
                    map.put("homePageType", homePageType);
                    map.put("homePageTypeStr", "默认");
                    break;
                case 2:
                    map.put("homePageType", homePageType);
                    map.put("homePageTypeStr", "员工");
                    break;
                case 3:
                    map.put("homePageType", homePageType);
                    map.put("homePageTypeStr", "商家");
                    break;
                default:
                    map.put("homePageType", -1);
                    map.put("homePageTypeStr", "未知");
            }
            Short loginStatus = null == map.get("loginStatus") ? -1 :  (Short) map.get("loginStatus");
            switch (loginStatus) {
                case 0:
                    map.put("loginStatus", loginStatus);
                    map.put("loginStatusStr", "正常");
                    break;
                case 1:
                    map.put("loginStatus", loginStatus);
                    map.put("loginStatusStr", "锁定");
                    break;
                case 2:
                    map.put("loginStatus", loginStatus);
                    map.put("loginStatusStr", "禁用");
                    break;
                default:
                    map.put("loginStatus", -1);
                    map.put("loginStatusStr", "未知");
            }
            if (null != map.get("loginTime"))
                map.put("loginTime", DateTools.dateFormat((Date) map.get("loginTime"), DateTools.DATE_FORMAT_YMD));
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    /*innateServiceEnd*/
    /*以上内容请误删除或是移动，系统升级使用，用户代码请写入下方*/
}